﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DoAn_BumTruong_DesignPattern
{
    class CommentProxy : Abstract
    {
        CommentController cmctrl;
        public List<Comments> GetCommentByArticleID(string articleID)
        {
            if (cmctrl == null)
            {
                cmctrl = new CommentController();
            }
            return cmctrl.GetCommentByArticle(articleID);
        }
        //Call COunt comment by ArticleId
        public int CountComementByArticleID(string articleID)
        {
            if (cmctrl == null)
            {
                cmctrl = new CommentController();
            }
            return cmctrl.CountCommentByArticleID(articleID);
        }
        //Call Paging
        public List<Comments> Paging(string page, out int howManyPage)
        {
            if (cmctrl == null)
            {
                cmctrl = new CommentController();
            }
            return cmctrl.Paging(page, out howManyPage);
        }
        public override bool Add(object o)
        {
            try
            {
                if (cmctrl == null)
                {
                    cmctrl = new CommentController();
                }
                return cmctrl.Add(o);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public override bool Delete(object o)
        {
            throw new NotImplementedException();
        }

        public override bool Update(object o)
        {
            throw new NotImplementedException();
        }

        //Update ShowHide
        public bool UpdateShowHide(int commentId, bool sh)
        {
            try
            {
                if (cmctrl == null)
                    cmctrl = new CommentController();
                return cmctrl.UpdateShowHide(commentId, sh);
            }
            catch (Exception)
            {
                return false;
            }

        }
    }
}